@@ -0,0 +1,53 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+from __future__ import division |
|
| 4 |
+ |
|
| 5 |
+from django.conf import settings |
|
| 6 |
+from django.db import transaction |
|
| 7 |
+from django_logit import logit |
|
| 8 |
+from django_response import response |
|
| 9 |
+ |
|
| 10 |
+from mch.models import ConsumeInfoSubmitLogInfo |
|
| 11 |
+from statistic.models import ConsumeModelSaleStatisticInfo |
|
| 12 |
+from utils.error.errno_utils import ProductBrandStatusCode, ProductMachineStatusCode |
|
| 13 |
+ |
|
| 14 |
+ |
|
| 15 |
+WECHAT = settings.WECHAT |
|
| 16 |
+ |
|
| 17 |
+ |
|
| 18 |
+@logit |
|
| 19 |
+def querysn(request): |
|
| 20 |
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
|
|
| 21 |
+ model_id = request.POST.get('model_id', '')
|
|
| 22 |
+ sn = request.POST.get('sn', '')
|
|
| 23 |
+ |
|
| 24 |
+ if brand_id != settings.KODO_DEFAULT_BRAND_ID: |
|
| 25 |
+ return response(ProductBrandStatusCode.BRAND_NOT_MATCH) |
|
| 26 |
+ |
|
| 27 |
+ try: |
|
| 28 |
+ log = ConsumeInfoSubmitLogInfo.objects.get(brand_id=brand_id, model_id=model_id, serialNo=sn) |
|
| 29 |
+ except ConsumeModelSaleStatisticInfo.DoesNotExist: |
|
| 30 |
+ return response(ProductMachineStatusCode.SN_NOT_FOUND) |
|
| 31 |
+ |
|
| 32 |
+ return response(200, 'Query SN Success', u'查询序列号成功', data=log.data) |
|
| 33 |
+ |
|
| 34 |
+ |
|
| 35 |
+@logit |
|
| 36 |
+@transaction.atomic |
|
| 37 |
+def usecoupon(request): |
|
| 38 |
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
|
|
| 39 |
+ model_id = request.POST.get('model_id', '')
|
|
| 40 |
+ sn = request.POST.get('sn', '')
|
|
| 41 |
+ |
|
| 42 |
+ if brand_id != settings.KODO_DEFAULT_BRAND_ID: |
|
| 43 |
+ return response(ProductBrandStatusCode.BRAND_NOT_MATCH) |
|
| 44 |
+ |
|
| 45 |
+ try: |
|
| 46 |
+ log = ConsumeInfoSubmitLogInfo.objects.get(brand_id=brand_id, model_id=model_id, serialNo=sn) |
|
| 47 |
+ except ConsumeModelSaleStatisticInfo.DoesNotExist: |
|
| 48 |
+ return response(ProductMachineStatusCode.SN_NOT_FOUND) |
|
| 49 |
+ |
|
| 50 |
+ log.has_used = True |
|
| 51 |
+ log.save() |
|
| 52 |
+ |
|
| 53 |
+ return response(200, 'Use Coupon Success', u'核销优惠券成功') |
@@ -76,6 +76,7 @@ def admin_login_api(request): |
||
| 76 | 76 |
request.session['admin_id'] = administrator.admin_id |
| 77 | 77 |
|
| 78 | 78 |
return response(200, 'Admin Login Success', u'管理员登录成功', data={
|
| 79 |
+ 'admin_type': administrator.admin_type, |
|
| 79 | 80 |
'qrurl': settings.KODO_CLERK_AUTH_URL.format(administrator.brand_id), |
| 80 | 81 |
}) |
| 81 | 82 |
|
@@ -5,7 +5,7 @@ from django_file_upload import views as file_views |
||
| 5 | 5 |
|
| 6 | 6 |
from account import tourguide_views |
| 7 | 7 |
from account import views as account_views |
| 8 |
-from api import clerk_views, distributor_views, encrypt_views, mch_views, model_views, operator_views |
|
| 8 |
+from api import admin_views, clerk_views, distributor_views, encrypt_views, mch_views, model_views, operator_views |
|
| 9 | 9 |
from box import views as box_views |
| 10 | 10 |
from geo import views as geo_views |
| 11 | 11 |
from group import (groupuser_views, lensman_views, tourguidegroup_views, tourguidegroupadmin_views, |
@@ -274,3 +274,8 @@ urlpatterns += [ |
||
| 274 | 274 |
url(r'^screen/admin/loginqr$', screen_views.screen_admin_loginqr, name='screen_admin_loginqr'), |
| 275 | 275 |
url(r'^screen/admin/loginrst$', screen_views.screen_admin_loginrst, name='screen_admin_loginrst'), |
| 276 | 276 |
] |
| 277 |
+ |
|
| 278 |
+urlpatterns += [ |
|
| 279 |
+ url(r'^admin/querysn$', admin_views.querysn, name='querysn'), |
|
| 280 |
+ url(r'^admin/usecoupon$', admin_views.usecoupon, name='usecoupon'), |
|
| 281 |
+] |
@@ -13,8 +13,8 @@ from mch.models import (ActivityInfo, AdministratorInfo, BrandInfo, ConsumeInfoS |
||
| 13 | 13 |
|
| 14 | 14 |
|
| 15 | 15 |
class AdministratorInfoAdmin(admin.ModelAdmin): |
| 16 |
- list_display = ('admin_id', 'phone', 'password', 'encryption', 'name', 'brand_id', 'brand_name', 'user_status', 'status', 'created_at', 'updated_at')
|
|
| 17 |
- list_filter = ('user_status', 'status', 'brand_name')
|
|
| 16 |
+ list_display = ('admin_id', 'admin_type', 'phone', 'password', 'encryption', 'name', 'brand_id', 'brand_name', 'user_status', 'status', 'created_at', 'updated_at')
|
|
| 17 |
+ list_filter = ('admin_type', 'user_status', 'status', 'brand_name')
|
|
| 18 | 18 |
readonly_fields = ('encryption', 'brand_name')
|
| 19 | 19 |
|
| 20 | 20 |
def save_model(self, request, obj, form, change): |
@@ -0,0 +1,30 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.20 on 2019-06-25 06:43 |
|
| 3 |
+from __future__ import unicode_literals |
|
| 4 |
+ |
|
| 5 |
+from django.db import migrations, models |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+class Migration(migrations.Migration): |
|
| 9 |
+ |
|
| 10 |
+ dependencies = [ |
|
| 11 |
+ ('mch', '0034_auto_20190620_1709'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.AddField( |
|
| 16 |
+ model_name='administratorinfo', |
|
| 17 |
+ name='admin_type', |
|
| 18 |
+ field=models.IntegerField(choices=[(0, '\u7ba1\u7406\u5458'), (1, '\u7ef4\u4fee\u5458')], db_index=True, default=0, help_text='\u7ba1\u7406\u5458\u7c7b\u578b', verbose_name='admin_type'), |
|
| 19 |
+ ), |
|
| 20 |
+ migrations.AddField( |
|
| 21 |
+ model_name='consumeinfosubmitloginfo', |
|
| 22 |
+ name='has_used', |
|
| 23 |
+ field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u5df2\u6838\u9500', verbose_name='has_used'), |
|
| 24 |
+ ), |
|
| 25 |
+ migrations.AlterField( |
|
| 26 |
+ model_name='activityinfo', |
|
| 27 |
+ name='coupon_expire_type', |
|
| 28 |
+ field=models.IntegerField(choices=[(0, '\u56fa\u5b9a\u7ed3\u675f\u65f6\u95f4'), (1, '\u53ef\u53d8\u7ed3\u675f\u65f6\u95f4')], default=0, help_text='\u7ef4\u4fee\u5238\u7c7b\u578b', verbose_name='coupon_expire_type'), |
|
| 29 |
+ ), |
|
| 30 |
+ ] |
@@ -11,6 +11,14 @@ from TimeConvert import TimeConvert as tc |
||
| 11 | 11 |
|
| 12 | 12 |
|
| 13 | 13 |
class AdministratorInfo(BaseModelMixin): |
| 14 |
+ ADMINISTRATOR = 0 |
|
| 15 |
+ MAINTENANCE = 1 |
|
| 16 |
+ |
|
| 17 |
+ USER_TYPE_TUPLE = ( |
|
| 18 |
+ (ADMINISTRATOR, u'管理员'), |
|
| 19 |
+ (MAINTENANCE, u'维修员'), |
|
| 20 |
+ ) |
|
| 21 |
+ |
|
| 14 | 22 |
ACTIVATED = 1 |
| 15 | 23 |
DISABLED = 2 |
| 16 | 24 |
DELETED = 3 |
@@ -23,6 +31,8 @@ class AdministratorInfo(BaseModelMixin): |
||
| 23 | 31 |
|
| 24 | 32 |
admin_id = ShortUUIDField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'管理员唯一标识', db_index=True, unique=True) |
| 25 | 33 |
|
| 34 |
+ admin_type = models.IntegerField(_(u'admin_type'), choices=USER_TYPE_TUPLE, default=ADMINISTRATOR, help_text=u'管理员类型', db_index=True) |
|
| 35 |
+ |
|
| 26 | 36 |
phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'管理员电话', db_index=True) |
| 27 | 37 |
password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'管理员密码') |
| 28 | 38 |
encryption = models.CharField(_(u'encryption'), max_length=255, blank=True, null=True, help_text=u'管理员密码') |
@@ -496,6 +506,7 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
| 496 | 506 |
activity_id = models.IntegerField(_(u'activity_id'), default=0, help_text=_(u'活动唯一标识')) |
| 497 | 507 |
coupon_expire_at = models.DateTimeField(_(u'coupon_expire_at'), blank=True, null=True, help_text=_(u'维修券过期时间')) |
| 498 | 508 |
coupon_value = models.IntegerField(_(u'coupon_value'), default=0, help_text=_(u'维修券金额(单位:分)')) |
| 509 |
+ has_used = models.BooleanField(_(u'has_used'), default=False, help_text=_(u'是否已核销'), db_index=True) |
|
| 499 | 510 |
|
| 500 | 511 |
test_user = models.BooleanField(_(u'test_user'), default=False, help_text=_(u'是否为测试用户'), db_index=True) |
| 501 | 512 |
|
@@ -523,7 +534,7 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
| 523 | 534 |
|
| 524 | 535 |
@property |
| 525 | 536 |
def data(self): |
| 526 |
- if self.submit_during_activity: |
|
| 537 |
+ if self.submit_during_activity and not self.has_used: |
|
| 527 | 538 |
try: |
| 528 | 539 |
act = ActivityInfo.objects.get(pk=self.activity_id) |
| 529 | 540 |
except ActivityInfo.DoesNotExist: |
@@ -28,10 +28,15 @@ class ProductModelStatusCode(BaseStatusCode): |
||
| 28 | 28 |
|
| 29 | 29 |
|
| 30 | 30 |
class ProductDistributorStatusCode(BaseStatusCode): |
| 31 |
- """ 经销商相关错误码 5011xx """ |
|
| 31 |
+ """ 经销商相关错误码 5012xx """ |
|
| 32 | 32 |
DISTRIBUTOR_NOT_FOUND = StatusCodeField(501201, 'Distributor Not Found', description=u'经销商不存在') |
| 33 | 33 |
|
| 34 | 34 |
|
| 35 |
+class ProductMachineStatusCode(BaseStatusCode): |
|
| 36 |
+ """ 机器相关错误码 5013xx """ |
|
| 37 |
+ SN_NOT_FOUND = StatusCodeField(501301, 'SN Not Found', description=u'序列号不存在') |
|
| 38 |
+ |
|
| 39 |
+ |
|
| 35 | 40 |
class ProductStatusCode(BaseStatusCode): |
| 36 | 41 |
""" 产品相关错误码 5020xx """ |
| 37 | 42 |
PRODUCT_NOT_FOUND = StatusCodeField(502001, 'Product Not Found', description=u'产品不存在') |